Repository navigation
feat(wiring): write Codex OPENAI_API_KEY into auth.json - #45
Merged
Merged
Conversation
Add applyCodexAuthWiring in src/main/wiring/codexAuth.ts. It merges OPENAI_API_KEY into ~/.codex/auth.json, preserves existing keys, writes atomically via writeJsonAtomic at 0600, and skips with an env note on non-macOS platforms, when file storage is disabled, or when no key is supplied. applyWiring for codex now returns both the config.toml and auth.json results, so the app IPC and the CLI (thin re-export) pick it up with no extra change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed: Codex wiring now writes
OPENAI_API_KEYinto~/.codex/auth.json(merged, atomic, 0600) alongside the existingconfig.tomlprovider block, so a fresh shell does not need the env var set.Closes #16
How it was verified:
mise run ci:app- passed (typecheck, lint, unit tests including the new codex-auth cases, and full build)mise run ci:cli- passed (typecheck and compiled CLI build). The CLI picks this up with no change becausecli/src/lib/wiring.tsre-exportsapplyWiringfrom the shared wiring layer.Proof (logic-only slice, no live provider key used):
New tests in
scripts/test-codex-auth.mjs, run as part ofnpm test:Fixture run against the built writer, credential redacted, existing content preserved:
Reviewer notes:
src/main/wiring/codexAuth.ts.applyWiringfor codex now returns two entries in the result array (config.toml, then auth.json), so both show up in the IPC response. The skip case still returns an entry withchanged: falseand the note, so the renderer can surface it.codexbinary picks the key up from auth.json in a fresh shell needs a real Codex install and a real key, which this run did not use. The file shape, merge, and permissions are covered by the tests above.